package isquirrel.servlets;


import isquirrel.LikeWorker;
import isquirrel.RecWorker;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class WorkersListener implements ServletContextListener{
	
	private static final long serialVersionUID = 1L;
	private RecWorker rec_thread = null;
	private LikeWorker like_thread = null;

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {

		rec_thread.stopThread();
		like_thread.stopThread();
		
	}


	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		
//		System.out.println("starting rec worker..");
		rec_thread = new RecWorker();
		rec_thread.setPriority(Thread.MIN_PRIORITY);
		rec_thread.start();
		
//		System.out.println("starting like worker..");
		like_thread = new LikeWorker();
		like_thread.setPriority(Thread.MIN_PRIORITY);
		like_thread.start();
		
	}
	


}
